<?php

namespace addons\shop\model;

use think\Model;
use addons\shop\model\UserCoupon;
use addons\shop\library\coupon\ToCalculate;
use addons\shop\library\coupon\Discount;
use addons\shop\library\coupon\FullReduction;
use addons\shop\model\Order;
use addons\shop\library\IntCode;

class TrainEnroll extends Model
{

    // 表名
    protected $name = 'train_enroll';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;


    /**
     * 获取列表
     * @param $param
     * @return \think\Paginator
     */
    public static function tableList($param)
    {

        $pageNum = 5;
        if (isset($param['num']) && !empty($param['num'])) {
            $pageNum = $param['num'];
        }
        $w['query']=$param;
        return self::where(function ($query) use ($param) {

            if (isset($param['type']) && !empty($param['type'])) {
                $query->where('type', $param['type']);
            }

            if (isset($param['is_open']) && !empty($param['is_open'])) {
                $query->where('is_open', $param['is_open']);
            }

            if (isset($param['result']) && $param['result'] != '') {
                $query->where('result', $param['result']);
            }
            if (isset($param['uid']) && $param['uid'] != '') {
                $query->where('uid', $param['uid']);
            }
        })->order('createtime desc')->paginate($pageNum,false,$w);
    }
}
